
#include "def_var.h"
#include <stdio.h>
#include "hx711.h"

#define LED5_PORT  GPIOB
#define LED5_Power_PIN    GPIO_PIN_15
#define	LED5_PowerOn	GPIO_ResetBits(LED5_PORT,	LED5_Power_PIN)
#define	LED5_PowerOff	GPIO_SetBits(LED5_PORT,	LED5_Power_PIN)
#define LED6_PORT  GPIOA
#define LED6_Power_PIN    GPIO_PIN_3
#define	LED6_PowerOn	GPIO_ResetBits(LED6_PORT,	LED6_Power_PIN)
#define	LED6_PowerOff	GPIO_SetBits(LED6_PORT,	LED6_Power_PIN)

#define KEY_INPUT_PORT        GPIOA
#define	KEY_ZERO_PIN		 GPIO_PIN_1
#define KEY1_PIN         GPIO_PIN_4
#define KEY2_PIN         GPIO_PIN_5
#define KEY3_PIN         GPIO_PIN_6
#define KEY4_PIN         GPIO_PIN_7
#define KEY_INPUT_EXTI_LINE   EXTI_LINE4
#define KEY_INPUT_PORT_SOURCE GPIOA_PORT_SOURCE
#define KEY_INPUT_PIN_SOURCE  GPIO_PIN_SOURCE4
#define KEY_INPUT_IRQn        EXTI4_15_IRQn

#define	TZ_PORT	GPIOA
#define	TZ_PWR_PIN	GPIO_PIN_12

//#define	TZPowerOn	GPIO_SetBits(TZ_PORT,TZ_PWR_PIN); \
//					machine.TZSensorPower = true
						
//#define	TZPowerOff	GPIO_ResetBits(TZ_PORT,TZ_PWR_PIN); \
//					machine.TZSensorPower = false
void TZPowerOff(void);
void TZPowerOn(void);
					
#define	FAN_CTL_PORT	GPIOB
#define	FAN_CTL_PIN		GPIO_PIN_4
#define	SHUI_CTL_PORT	GPIOB
#define	SHUI_CTL_PIN	GPIO_PIN_3
#define	WUFHUA_CTL_PORT	GPIOB
#define	WUFHUA_CTL_PIN	GPIO_PIN_5

//#define	FanPowerOn		GPIO_SetBits(FAN_CTL_PORT, FAN_CTL_PIN) ; \
//					machine.FanPower = true
//#define	FanPowerOff		GPIO_ResetBits(FAN_CTL_PORT, FAN_CTL_PIN)	; \
//					machine.FanPower = false
					
//#define	ShuiFaPowerOn			GPIO_SetBits(SHUI_CTL_PORT,	SHUI_CTL_PIN) ; \
//					machine.ShuiFaPower = true
//#define	ShuiFaPowerOff			GPIO_ResetBits(SHUI_CTL_PORT,	SHUI_CTL_PIN) ;\
//					machine.ShuiFaPower = false
						
//#define	WuHuaPowerOn			GPIO_SetBits(WUFHUA_CTL_PORT,	WUFHUA_CTL_PIN) ;\
//					machine.WuHuaPower = true
//#define	WuHuaPowerOff			GPIO_ResetBits(WUFHUA_CTL_PORT,	WUFHUA_CTL_PIN)	; \
//					machine.WuHuaPower = false


#define	CHOUYE_CTL_PORT	GPIOA
#define	CHOUYE_CTL_PIN	GPIO_PIN_15
//#define ChouYePowerOn			GPIO_SetBits(CHOUYE_CTL_PORT,	CHOUYE_CTL_PIN) ; \
//					machine.ChuChouYePower = true
//#define	ChouYePowerOff			GPIO_ResetBits(CHOUYE_CTL_PORT,	CHOUYE_CTL_PIN) ; \
//					machine.ChuChouYePower = false

#define	BuzzerPort	GPIOA
#define	BuzzerPin		GPIO_PIN_2
#define	BuzzerPowerOn	GPIO_SetBits(BuzzerPort,	BuzzerPin)
#define	BuzzerPowerOff	GPIO_ResetBits(BuzzerPort,	BuzzerPin)

#define CALIBRATE_WEIGHT  100 // (unit:g)

void KeyInputExtiInit(GPIO_Module* GPIOx, uint16_t Pin);


extern	void	RAM_Initial(void);
extern	void	InitialMonitor(void);
extern	void	InitialSensor(void);
extern	void	Check_Sensor(void);
extern	void	TZ_Sensor_PowerOn(bool);
extern 	void RTC_GetTime(uint32_t RTC_Format, RTC_TimeType* RTC_TimeStruct);
extern	float Get_Weight(void);
extern	void	InitialWorkingTime(void);
extern  U8 Check_Water_Sensor(void);

extern	void delay_ms(u16 nms);
